package com.wsdcd.zlg.model.service.impl;

import com.wsdcd.zlg.mapper.UserMapper;
import com.wsdcd.zlg.model.entity.User;
import com.wsdcd.zlg.model.service.UserService;
import com.wsdcd.zlg.util.PageUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@AllArgsConstructor
@Service("userService")
public class UserServiceImpl implements UserService {
    private final UserMapper userMapper;

    @Override
    public void insert(User user) {
        userMapper.insert(user);
    }

    @Override
    public void delete(int id) {
        userMapper.delete(id);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    @Override
    public List<User> select() {
        return userMapper.select();
    }

    @Override
    public User selectById(int id) {
        return userMapper.selectById(id);
    }

    @Override
    public List<User> selectByPage(int page, int limit) {

        PageUtil pageUtil = new PageUtil( (page-1)*limit ,limit);
        return userMapper.selectByPage(pageUtil);
    }
}
